<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>病案首页</title>
    <style>
        :root {
            --primary-color: #1890ff;
            --border-color: #e8e8e8;
            --text-color: #333;
            --error-color: #ff4d4f;
            --success-color: #52c41a;
            --bg-gray: #f5f5f5;
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
            line-height: 1.6;
            color: var(--text-color);
            background-color: #fff;
            padding: 20px;
            max-width: 1200px;
            margin: 0 auto;
        }

        .container {
            background: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
            padding: 24px;
            margin-bottom: 24px;
        }

        .page-header {
            text-align: center;
            margin-bottom: 32px;
            padding: 24px 0;
            border-bottom: 2px solid var(--primary-color);
        }

        .org-title {
            font-size: 28px;
            font-weight: bold;
            color: var(--primary-color);
            margin-bottom: 8px;
        }

        .page-title {
            font-size: 24px;
            font-weight: bold;
            margin: 16px 0;
        }

        .section-title {
            font-size: 18px;
            font-weight: 600;
            margin: 24px 0 16px;
            padding-left: 12px;
            border-left: 4px solid var(--primary-color);
        }

        .form-section {
            background: #fff;
            padding: 20px;
            margin-bottom: 24px;
            border-radius: 6px;
            border: 1px solid var(--border-color);
        }

        .field-row {
            display: flex;
            flex-wrap: wrap;
            margin-bottom: 12px;
            gap: 24px;
        }

        .field-item {
            flex: 1 1 300px;
            min-width: 300px;
            display: flex;
            align-items: center;
        }

        .field-label {
            min-width: 120px;
            color: #666;
            font-weight: 500;
        }

        .field-value {
            flex: 1;
            padding: 4px 8px;
            background: var(--bg-gray);
            border-radius: 4px;
        }

        .validation-errors {
            background-color: #fff2f0;
            border: 1px solid var(--error-color);
            border-radius: 6px;
            padding: 16px;
            margin-bottom: 24px;
        }

        .validation-errors h3 {
            color: var(--error-color);
            margin-bottom: 8px;
            font-size: 16px;
        }

        .validation-errors ul {
            margin: 0;
            padding-left: 20px;
        }

        .validation-errors li {
            color: var(--error-color);
            margin-bottom: 4px;
        }

        .surgery-table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            overflow: hidden;
            margin: 16px 0;
        }

        .surgery-table th {
            background: #fafafa;
            padding: 12px 8px;
            text-align: left;
            font-weight: 600;
            border-bottom: 1px solid var(--border-color);
        }

        .surgery-table td {
            padding: 12px 8px;
            border-bottom: 1px solid var(--border-color);
        }

        .surgery-table tr:last-child td {
            border-bottom: none;
        }

        .billing-section {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 16px;
            margin-top: 24px;
        }

        .billing-item {
            background: var(--bg-gray);
            padding: 12px;
            border-radius: 6px;
        }

        .error {
            color: var(--error-color);
            font-weight: 500;
        }

        @media (max-width: 768px) {
            body {
                padding: 12px;
            }

            .container {
                padding: 16px;
            }

            .field-item {
                flex: 1 1 100%;
            }

            .surgery-table {
                display: block;
                overflow-x: auto;
            }
        }

        .section-subtitle {
            font-size: 16px;
            font-weight: 600;
            color: var(--text-color);
            margin: 16px 0 12px;
            padding-left: 8px;
            border-left: 3px solid var(--primary-color);
        }

        .billing-summary {
            background: var(--bg-gray);
            border-radius: 6px;
            padding: 16px;
            margin-top: 12px;
        }

        .summary-row {
            display: flex;
            gap: 24px;
            margin-bottom: 16px;
        }

        .summary-row:last-child {
            margin-bottom: 0;
        }

        .summary-item {
            flex: 1;
            background: white;
            padding: 12px;
            border-radius: 4px;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .summary-label {
            display: block;
            color: #666;
            margin-bottom: 4px;
            font-weight: 500;
        }

        .summary-value {
            display: block;
            font-size: 18px;
            font-weight: 600;
            color: var(--primary-color);
        }

        @media (max-width: 768px) {
            .summary-row {
                flex-direction: column;
                gap: 12px;
            }
            
            .summary-item {
                width: 100%;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <#-- 校验错误提示区 -->
        <#if validationErrors?? && validationErrors?size gt 0>
        <div class="validation-errors">
            <h3>数据校验错误</h3>
            <ul>
                <#list validationErrors as error>
                    <li>${error}</li>
                </#list>
            </ul>
        </div>
        </#if>

        <#-- 页眉 -->
        <div class="page-header">
            <div class="org-title">${(facilityInfo.orgName)!''}</div>
            <div>组织机构编码：${(facilityInfo.orgCode)!''}</div>
            <div class="page-title">住 院 病 案 首 页</div>
        </div>

        <#-- 基本信息区 -->
        <div class="form-section">
            <div class="section-title">基本信息</div>
            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">病案号</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.medicalRecordId)>error</#if>">${(patientInfo.medicalRecordId)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">健康卡号</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.healthCard)>error</#if>">${(patientInfo.healthCard)!''}</span>
                </div>
            </div>
            
            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">姓名</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.name)>error</#if>">${(patientInfo.name)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">性别</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.gender)>error</#if>">${(patientInfo.gender)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">出生日期</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.birthDate)>error</#if>"><#if patientInfo.birthDate??>${patientInfo.birthDate}</#if></span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">年龄</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.age)>error</#if>">${(patientInfo.age)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">国籍</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.nationality)>error</#if>">${(patientInfo.nationality)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">民族</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (patientInfo.ethnicity!''))>error</#if>">${(patientInfo.ethnicity)!''}</span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">身份证号</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (patientInfo.idNumber!''))>error</#if>">${(patientInfo.idNumber)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">职业</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (patientInfo.occupation!''))>error</#if>">${(patientInfo.occupation)!''}</span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">现住址</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (patientInfo.currentAddress!''))>error</#if>">${(patientInfo.currentAddress)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">电话</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (patientInfo.phone!''))>error</#if>">${(patientInfo.phone)!''}</span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">户口地址</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.registeredAddress)>error</#if>">${(patientInfo.registeredAddress)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">邮编</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.postalCode)>error</#if>">${(patientInfo.postalCode)!''}</span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">工作单位</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.workUnit)>error</#if>">${(patientInfo.workUnit)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">单位电话</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.workPhone)>error</#if>">${(patientInfo.workPhone)!''}</span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">联系人姓名</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.contactName)>error</#if>">${(patientInfo.contactName)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">联系人关系</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.contactRelation)>error</#if>">${(patientInfo.contactRelation)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">联系人电话</span>
                    <span class="field-value <#if hasFacialError(validationErrors, patientInfo.contactPhone)>error</#if>">${(patientInfo.contactPhone)!''}</span>
                </div>
            </div>
        </div>

        <#-- 入院信息区 -->
        <div class="form-section">
            <div class="section-title">入院信息</div>
            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">入院时间</span>
                    <span class="field-value <#if hasFacialError(validationErrors, admissionInfo.admissionTime)>error</#if>"><#if admissionInfo?? && admissionInfo.admissionTime??>${admissionInfo.admissionTime}</#if></span>
                </div>
                <div class="field-item">
                    <span class="field-label">入院科别</span>
                    <span class="field-value <#if hasFacialError(validationErrors, admissionInfo.admissionDept)>error</#if>">${(admissionInfo.admissionDept)!''}</span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">转科科别</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (admissionInfo.transferDept!''))>error</#if>">${(admissionInfo.transferDept)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">出院时间</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (admissionInfo.dischargeTime!''))>error</#if>"><#if admissionInfo?? && admissionInfo.dischargeTime??>${admissionInfo.dischargeTime}</#if></span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">实际住院天数</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (admissionInfo.actualDays!''))>error</#if>">${(admissionInfo.actualDays)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">出院科别</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (admissionInfo.dischargeDept!''))>error</#if>">${(admissionInfo.dischargeDept)!''}</span>
                </div>
            </div>
        </div>

        <#-- 诊断信息区 -->
        <div class="form-section">
            <div class="section-title">诊断信息</div>
            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">门（急）诊诊断</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (admissionInfo.erDiagnosis!''))>error</#if>">${(admissionInfo.erDiagnosis)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">疾病编码</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (admissionInfo.erDiagCode!''))>error</#if>">${(admissionInfo.erDiagCode)!''}</span>
                </div>
            </div>

            <#if diagnosisList?? && diagnosisList?size gt 0>
            <div class="field-row">
                <div class="field-item" style="flex: 1 1 100%;">
                    <span class="field-label">出院诊断</span>
                    <div class="field-value" style="flex-direction: column;">
                        <#list diagnosisList as diagnosis>
                            <div class="<#if hasFacialError(validationErrors, diagnosis.diagnosisName)>error</#if>">
                                ${diagnosis.diagnosisName!''} (${diagnosis.diagCode!''})
                            </div>
                        </#list>
                    </div>
                </div>
            </div>
            </#if>
        </div>

        <#-- 手术信息区 -->
        <#if surgeryInfo??>
        <div class="form-section">
            <div class="section-title">手术及操作信息</div>
            <div style="overflow-x: auto;">
                <table class="surgery-table">
                    <thead>
                        <tr>
                            <th>手术编码</th>
                            <th>手术日期</th>
                            <th>手术名称</th>
                            <th>级别</th>
                            <th>术者</th>
                            <th>Ⅰ助</th>
                            <th>Ⅱ助</th>
                            <th>切口愈合</th>
                            <th>麻醉方式</th>
                            <th>麻醉医师</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.surgeryCode!''))>error</#if>">${(surgeryInfo.surgeryCode)!''}</td>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.surgeryDate!''))>error</#if>"><#if surgeryInfo.surgeryDate??>${surgeryInfo.surgeryDate}</#if></td>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.surgeryName!''))>error</#if>">${(surgeryInfo.surgeryName)!''}</td>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.surgeryLevel!''))>error</#if>">${(surgeryInfo.surgeryLevel)!''}</td>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.surgeon!''))>error</#if>">${(surgeryInfo.surgeon)!''}</td>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.firstAssistant!''))>error</#if>">${(surgeryInfo.firstAssistant)!''}</td>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.secondAssistant!''))>error</#if>">${(surgeryInfo.secondAssistant)!''}</td>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.woundHealingLevel!''))>error</#if>">${(surgeryInfo.woundHealingLevel)!''}</td>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.anesthesiaMethod!''))>error</#if>">${(surgeryInfo.anesthesiaMethod)!''}</td>
                            <td class="<#if hasFacialError(validationErrors, (surgeryInfo.anesthesiologist!''))>error</#if>">${(surgeryInfo.anesthesiologist)!''}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        </#if>

        <#-- 费用信息区 -->
        <#if billingInfo??>
        <div class="form-section">
            <div class="section-title">费用信息</div>
            <div class="billing-section">
                <div class="billing-item">
                    <span class="field-label">总费用</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.totalCost)>error</#if>">${formatMoney(billingInfo.totalCost)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">自付金额</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.selfPay)>error</#if>">${formatMoney(billingInfo.selfPay)}</span>
                </div>

                <div class="billing-item">
                    <span class="field-label">一般医疗服务费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (billingInfo.generalMedicalService!''))>error</#if>">${formatMoney(billingInfo.generalMedicalService)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">一般治疗操作费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.generalTreatmentOperation)>error</#if>">${formatMoney(billingInfo.generalTreatmentOperation)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">护理费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.nursingFee)>error</#if>">${formatMoney(billingInfo.nursingFee)}</span>
                </div>

                <div class="billing-item">
                    <span class="field-label">病理诊断费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (billingInfo.pathologyDiagnosis!''))>error</#if>">${formatMoney(billingInfo.pathologyDiagnosis)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">实验室诊断费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (billingInfo.laboratoryDiagnosis!''))>error</#if>">${formatMoney(billingInfo.laboratoryDiagnosis)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">影像学诊断费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.imagingDiagnosis)>error</#if>">${formatMoney(billingInfo.imagingDiagnosis)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">临床诊断项目费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.clinicalDiagnosis)>error</#if>">${formatMoney(billingInfo.clinicalDiagnosis)}</span>
                </div>

                <div class="billing-item">
                    <span class="field-label">非手术治疗项目费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.nonSurgicalTreatment)>error</#if>">${formatMoney(billingInfo.nonSurgicalTreatment)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">手术治疗费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.surgicalTreatment)>error</#if>">${formatMoney(billingInfo.surgicalTreatment)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">康复费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.rehabilitation)>error</#if>">${formatMoney(billingInfo.rehabilitation)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">中医治疗费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.tcmTreatment)>error</#if>">${formatMoney(billingInfo.tcmTreatment)}</span>
                </div>

                <div class="billing-item">
                    <span class="field-label">西药费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.westernMedicine)>error</#if>">${formatMoney(billingInfo.westernMedicine)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">中成药费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.chinesePatentMedicine)>error</#if>">${formatMoney(billingInfo.chinesePatentMedicine)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">中草药费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.chineseHerbalMedicine)>error</#if>">${formatMoney(billingInfo.chineseHerbalMedicine)}</span>
                </div>

                <div class="billing-item">
                    <span class="field-label">血费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.bloodFee)>error</#if>">${formatMoney(billingInfo.bloodFee)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">白蛋白类制品费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.albumin)>error</#if>">${formatMoney(billingInfo.albumin)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">球蛋白类制品费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.globulin)>error</#if>">${formatMoney(billingInfo.globulin)}</span>
                </div>

                <div class="billing-item">
                    <span class="field-label">检查用一次性医用材料费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.disposableExamMaterials)>error</#if>">${formatMoney(billingInfo.disposableExamMaterials)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">治疗用一次性医用材料费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.disposableTreatMaterials)>error</#if>">${formatMoney(billingInfo.disposableTreatMaterials)}</span>
                </div>
                <div class="billing-item">
                    <span class="field-label">手术用一次性医用材料费</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.disposableSurgeryMaterials)>error</#if>">${formatMoney(billingInfo.disposableSurgeryMaterials)}</span>
                </div>

                <div class="billing-item">
                    <span class="field-label">其他费用</span>
                    <span class="field-value <#if hasFacialError(validationErrors, billingInfo.otherCosts)>error</#if>">${formatMoney(billingInfo.otherCosts)}</span>
                </div>
            </div>

            <#-- 费用分类统计 -->
            <div class="section-subtitle" style="margin-top: 20px;">费用分类统计</div>
            <div class="billing-summary">
                <div class="summary-row">
                    <div class="summary-item">
                        <span class="summary-label">诊断费用合计</span>
                        <span class="summary-value">
                            ${((billingInfo.pathologyDiagnosis!0) + 
                               (billingInfo.laboratoryDiagnosis!0) + 
                               (billingInfo.imagingDiagnosis!0) + 
                               (billingInfo.clinicalDiagnosis!0))!0}
                        </span>
                    </div>
                    <div class="summary-item">
                        <span class="summary-label">治疗费用合计</span>
                        <span class="summary-value">
                            ${((billingInfo.nonSurgicalTreatment!0) + 
                               (billingInfo.surgicalTreatment!0) + 
                               (billingInfo.rehabilitation!0) + 
                               (billingInfo.tcmTreatment!0))!0}
                        </span>
                    </div>
                    <div class="summary-item">
                        <span class="summary-label">药品费用合计</span>
                        <span class="summary-value">
                            ${((billingInfo.westernMedicine!0) + 
                               (billingInfo.chinesePatentMedicine!0) + 
                               (billingInfo.chineseHerbalMedicine!0))!0}
                        </span>
                    </div>
                </div>
                <div class="summary-row">
                    <div class="summary-item">
                        <span class="summary-label">血液和制品费用合计</span>
                        <span class="summary-value">
                            ${((billingInfo.bloodFee!0) + 
                               (billingInfo.albumin!0) + 
                               (billingInfo.globulin!0))!0}
                        </span>
                    </div>
                    <div class="summary-item">
                        <span class="summary-label">医用材料费合计</span>
                        <span class="summary-value">
                            ${((billingInfo.disposableExamMaterials!0) + 
                               (billingInfo.disposableTreatMaterials!0) + 
                               (billingInfo.disposableSurgeryMaterials!0))!0}
                        </span>
                    </div>
                </div>
            </div>
        </div>
        </#if>

        <#-- 医疗团队 -->
        <#if medicalTeam??>
        <div class="form-section">
            <div class="section-title">医疗团队</div>
            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">科主任</span>
                    <span class="field-value <#if hasFacialError(validationErrors, medicalTeam.departmentHead?string!'')>error</#if>">${(medicalTeam.departmentHead)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">主治医师</span>
                    <span class="field-value <#if hasFacialError(validationErrors, medicalTeam.attending?string!'')>error</#if>">${(medicalTeam.attending)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">住院医师</span>
                    <span class="field-value <#if hasFacialError(validationErrors, medicalTeam.resident?string!'')>error</#if>">${(medicalTeam.resident)!''}</span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">责任护士</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (medicalTeam.nurse!''))>error</#if>">${(medicalTeam.nurse)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">进修医师</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (medicalTeam.trainee!''))>error</#if>">${(medicalTeam.trainee)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">实习医师</span>
                    <span class="field-value <#if hasFacialError(validationErrors, (medicalTeam.intern!''))>error</#if>">${(medicalTeam.intern)!''}</span>
                </div>
            </div>

            <div class="field-row">
                <div class="field-item">
                    <span class="field-label">病案质量</span>
                    <span class="field-value <#if hasFacialError(validationErrors, medicalTeam.qualityGrade)>error</#if>">${(medicalTeam.qualityGrade)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">质控医师</span>
                    <span class="field-value <#if hasFacialError(validationErrors, medicalTeam.qcDoctor)>error</#if>">${(medicalTeam.qcDoctor)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">质控护士</span>
                    <span class="field-value <#if hasFacialError(validationErrors, medicalTeam.qcNurse)>error</#if>">${(medicalTeam.qcNurse)!''}</span>
                </div>
                <div class="field-item">
                    <span class="field-label">质控日期</span>
                    <span class="field-value <#if hasFacialError(validationErrors, medicalTeam.qcDate)>error</#if>"><#if medicalTeam.qcDate??>${medicalTeam.qcDate}</#if></span>
                </div>
            </div>
        </div>
        </#if>
    </div>
</body>
</html>

<#-- 自定义函数：检查字段值是否在校验错误中出现 -->
<#function hasFacialError errors fieldValue>
    <#if errors?? && errors?size gt 0>
        <#if fieldValue??>
            <#list errors as error>
                <#if error??>
                    <#-- 确保将字段值转换为字符串 -->
                    <#if fieldValue?is_number>
                        <#local fieldStr = fieldValue?string>
                    <#elseif fieldValue?is_date>
                        <#local fieldStr = fieldValue?string["yyyy-MM-dd HH:mm:ss"]>
                    <#elseif fieldValue?is_boolean>
                        <#local fieldStr = fieldValue?string>
                    <#else>
                        <#local fieldStr = fieldValue?string>
                    </#if>
                    <#if error?contains(fieldStr)>
                        <#return true>
                    </#if>
                </#if>
            </#list>
        </#if>
    </#if>
    <#return false>
</#function>

<#-- 添加一个用于格式化金额的函数 -->
<#function formatMoney value>
    <#if value??>
        <#return value?string(",##0.00")>
    </#if>
    <#return "0.00">
</#function> 